#include <stdio.h>
#include <stdlib.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include "Functions.h"


int main()
{
    int quit=0,i=1000;
    perso kheop;
    SDL_Surface *screen;
    SDL_Surface *menu_screen;
    SDL_Surface *ico[11];
    SDL_Surface *fond[2];
    SDL_Event event;
  //  int k=0;
    SDL_Init(SDL_INIT_EVERYTHING);
    SDL_EnableKeyRepeat(70,35);
    menu_screen = SDL_SetVideoMode( 1300, 714, 32, SDL_HWSURFACE|SDL_DOUBLEBUF);
    load_menu(ico,fond);

    blitmenu(ico,fond,menu_screen,0,6,2,3,4,5);


    SDL_Flip(menu_screen);
    while(quit==0)
    {
        while (SDL_PollEvent(&event))
        {
            if(event.type==SDL_KEYDOWN)  if( event.key.keysym.sym==SDLK_DOWN )i++;
            if(event.type==SDL_KEYDOWN)  if( event.key.keysym.sym==SDLK_UP )i--;
            if(event.type==SDL_KEYDOWN)if(event.key.keysym.sym==SDLK_RIGHT)i=10003;

/////////////////////////////////////////////////////////////
            if(i%5==0)
            {
                blitmenu(ico,fond,menu_screen,0,6,2,3,4,5);
                if(event.type==SDL_KEYDOWN)if(event.key.keysym.sym==SDLK_RETURN){


    LoadPerso(&kheop,1);
   return play_Stage_one(screen,kheop);                                }

            }
            if(i%5==1)
            {
                blitmenu(ico,fond,menu_screen,0,1,7,3,4,5);

            }
            if(i%5==2)
            {
                blitmenu(ico,fond,menu_screen,0,1,2,8,4,5);

            }
            if(i%5==3)
            {
                blitmenu(ico,fond,menu_screen,0,1,2,3,9,5);
            }
            if(i%5==4)
            {
                ;
                blitmenu(ico,fond,menu_screen,0,1,2,3,4,10);
            }

            SDL_Flip(menu_screen);

            if( event.type == SDL_QUIT )
            {
                quit = 1;
            }

        }
    }

    SDL_FreeSurface(ico[1]);
    SDL_FreeSurface(ico[2]);
    SDL_FreeSurface(ico[3]);
    SDL_FreeSurface(ico[4]);
    SDL_FreeSurface(ico[5]);
    SDL_FreeSurface(ico[6]);
    SDL_FreeSurface(ico[7]);
    SDL_FreeSurface(ico[8]);
    SDL_FreeSurface(ico[9]);
    SDL_FreeSurface(ico[10]);
    SDL_FreeSurface(fond[0]);
    SDL_FreeSurface(fond[1]);

    SDL_FreeSurface(menu_screen);




return 0;
}
